﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Waegis.Client.Components;
using System.Net;
using Waegis.Client;

namespace Waegis.Tester
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void btnInitialize_Click(object sender, EventArgs e)
        {
            WaegisClient client = new WaegisClient(txtApiKey.Text, new Uri(txtSiteUrl.Text));
            MessageBox.Show(client.InitializeSiteInstance().ToString());
        }

        private void btnCheck_Click(object sender, EventArgs e)
        {
            Post post = GetPost();

            WaegisClient client = new WaegisClient(txtApiKey.Text, new Uri(txtSiteUrl.Text));
            MessageBox.Show(client.CheckPost(post).ToString());
        }

        private void btnReportSpam_Click(object sender, EventArgs e)
        {
            Post post = GetPost();

            WaegisClient client = new WaegisClient(txtApiKey.Text, new Uri(txtSiteUrl.Text));
            client.ReportSpam(post);

            MessageBox.Show("Spam Reported");
        }

        private void btnReportHam_Click(object sender, EventArgs e)
        {
            Post post = GetPost();

            WaegisClient client = new WaegisClient(txtApiKey.Text, new Uri(txtSiteUrl.Text));
            client.ReportHam(post);

            MessageBox.Show("Ham Reported");
        }

        private Post GetPost()
        {
            Post post = new Post();
            post.AuthorName = txtAuthor.Text;
            post.AuthorUrl = new Uri(txtUrl.Text);
            post.AuthorEmail = txtEmail.Text;
            post.Body = txtBody.Text;
            post.PostType = (PostType)cmbPostType.SelectedIndex;
            post.Permalink = new Uri("http://nayyeri.net/6598");
            post.UserIP = IPAddress.Parse(txtIPAddress.Text);
            post.UserAgent = txtUserAgent.Text;

            return post;
        }
    }
}
